//
//  MCCollectionViewCell.m
//  HM玉器街
//
//  Created by 李李善 on 16/8/30.
//  Copyright © 2016年 HM. All rights reserved.
//

#import "BaseCollectionViewCell.h"
#import "UIView+Base.h"


@implementation BaseCollectionViewCell
-(void)dealloc{
     NSLog(@"%@ 这个类被强暴了",NSStringFromClass([self class]));
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
    }
    return self;
}

+(UICollectionViewCell *)onCollectionView:(UICollectionView *)collectionView forViewController:(UIViewController *)ViewController dequeueReusableCellWithReuseIdentifier:(NSString *)identifier dataSource:(id)dataSource forIndexPath:(NSIndexPath *)indexPath
{
    BaseCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    if (NO ==cell.isAsInt) {
        cell.opaque = YES;
        [cell onAsInitAddView:cell.contentView forViewController:ViewController forDataSource:dataSource AtIndexPath:indexPath];
        
    }
    return cell;
}



-(void)onMainSetSubViewFrame:(void (^)(UIView *, CGPoint, CGSize, CGPoint))layoutBlock
{
    if (layoutBlock !=self.layoutBlock) {
        self.layoutBlock = layoutBlock;
    }
}
-(MCLabel *)detailLabel
{
    if (!_detailLabel) {
        MCLabel *textL = ({
            MCLabel*l=[MCLabel new];
            l.numberOfLines = 0;
            [self.contentView addV:l];
            l;
        });
        _detailLabel = textL;
    }
    return _detailLabel;
}

-(UILabel *)textLabel
{
    if (!_textLabel) {
        UILabel *textL = ({
            UILabel*l=[UILabel new];
            l.numberOfLines = 0;
            [self.contentView addV:l];
            l;
        });
        _textLabel = textL;
    }
    return _textLabel;
}

-(UIImageView *)imageView
{
    if (!_imageView) {
        UIImageView *imagev = ({
            UIImageView*l=[ UIImageView new];
            [self.contentView addV:l];
            l;
        });
        _imageView = imagev;
    }
    return _imageView;
    
}
-(HLTextField *)textField
{
    if (!_textField) {
        
        HLTextField*textF = ({
            HLTextField*l=[ HLTextField new];
            [self.contentView addV:l];
            l;
        });
        _textField = textF;
        
        
    }
    return _textField;
}

-(HLTextView *)textView
{
    if (!_textView) {
        HLTextView*textV = ({
            HLTextView*l=[ HLTextView new];
            [self.contentView addV:l];
            l;
        });
        _textView = textV;
        
    }
    return _textView;
}

-(UIButton *)button
{
    if (!_button) {
        UIButton *button = ({
            UIButton *l= [UIButton buttonWithType:UIButtonTypeCustom];
            [self.contentView addV:l];
            l;
        });
        _button = button;
    }
    return _button;
}



-(void)layoutSubviews
{
    [super layoutSubviews];
    CGRect frame = self.frame;
    if (self.layoutBlock) {
        self.layoutBlock(self.contentView,frame.origin,frame.size,self.center);
    }
    
}

@end
